package com.koron.css2.newProjectCenter.mapper;

import com.koron.css2.newProjectCenter.bean.query.PubUpNoticeQueryBean;
import com.koron.css2.newProjectCenter.vo.PubUpNoticeListVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PubUpNoticeMapper {

    List<PubUpNoticeListVO> selectUnknownList(PubUpNoticeQueryBean bean, @Param("account") String account);

    @Select("select * from pub_up_notice where is_deleted = false")
    List<PubUpNoticeListVO> selectAllList(PubUpNoticeQueryBean queryBean);

    int updateOrSave(PubUpNoticeQueryBean bean);

    int clearMessage(@Param("ids") String ids);

    @Insert("insert into pj_notice_read_record (id, account, notice_id, read_status) " +
            "values(#{id}, #{account}, #{noticeId}, #{readStatus})")
    void setMsgStatusByIds(
        @Param("id") String id,
        @Param("noticeId") String noticeId,
        @Param("account") String account,
        @Param("readStatus") int readStatus
    );
    
    @Select("select id from pub_up_notice where lose_time < now() and is_deleted = false")
    List<String> getExpiredMessageFromNotice();

    @Select("select id from pj_notice_read_record where notice_id = #{noticeId} and account = #{account} and is_deleted = false")
    String getRecordIdByNoticeIdAndAccount(@Param("noticeId") String noticeId, @Param("account") String account);

    void clearExpiredMessageFromNotice(@Param("ids") List<String> ids);

    void clearExpiredMessageFromRecord(@Param("ids") List<String> ids);
}
